package com.atmilan.quartz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.atmilan.quartz.mapper.MerchantCustomerMapper;
import com.atmilan.quartz.model.entity.buyer.MerchantCustomer;
import com.atmilan.quartz.model.entity.buyer.MerchantCustomerExample;
import com.atmilan.quartz.service.IMerchantCustomerService;

@Service
public class MerchantCustomerServiceImpl implements IMerchantCustomerService {
    @Autowired
    MerchantCustomerMapper merchantCustomerMapper;

    @Override
    public MerchantCustomer getByContactsMobilePhoneAndMerchantId(String mobilePhone, Long merchantId) {
        MerchantCustomerExample merchantCustomerExample = new MerchantCustomerExample();
        merchantCustomerExample.createCriteria().andMerchantIdEqualTo(merchantId).andContactsMobilePhoneEqualTo(mobilePhone);

        List<MerchantCustomer> list = merchantCustomerMapper.selectByExample(merchantCustomerExample);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }

}
